﻿using Adnc.Application.Shared.Dtos;
using Adnc.WebApi.Shared;
using Microsoft.AspNetCore.Mvc;
using WYT.Sys.Application.Contracts.Dtos.Encyclopedia;
using WYT.Sys.Application.Contracts.Services;

namespace WYT.Sys.WebApi.Controllers
{
    /// <summary>
    /// 百科
    /// </summary>
    [Route("sys/[Controller]")]
    [ApiController]
    public class EncyclopediaController : AdncControllerBase
    {

        public readonly IEncyclopediaAppService _encyclopediaAppService;

        public EncyclopediaController(IEncyclopediaAppService encyclopediaAppService)
        {
            _encyclopediaAppService = encyclopediaAppService;
        }


        /// <summary>
        /// 分组列表
        /// </summary>
        /// <returns></returns>
        [HttpGet("Groups")]
        public async Task<WYTActionResult<List<EncyclopediaGroupDto>>> GetGroupList([FromQuery]string language)
        {
            return Success(await _encyclopediaAppService.GetGroupList(language));
        }

        /// <summary>
        /// 分页获取问题与答案
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("Contents")]
        public async Task<WYTActionResult<PageModelDto<EncyclopediaContentDto>>> GetContentList([FromQuery] SearchPagedDto<long> input)
        {
            return Success(await _encyclopediaAppService.GetContentList(input));
        }
    }
}
